package com.koudai.reader.conponment;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.koudai.reader.SearchBookActivity;
import com.koudai.reader.android.R;

public class GotoSearchDialog extends Dialog {

    private TextView content;
    private Button gotoSearch;
    private ImageView back;
    
    public GotoSearchDialog(final Context context, String text, final String keyword) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.goto_search_view);
        
        back = (ImageView)findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                GotoSearchDialog.this.dismiss();     
            }
        });
        
        content = (TextView) findViewById(R.id.body);
        
        content.setText(Html.fromHtml(text));
        
        gotoSearch = (Button)findViewById(R.id.confirm_select);
        
        gotoSearch.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("keyword", keyword);
                intent.setClass(context, SearchBookActivity.class);
                context.startActivity(intent);
            }
        });
    }

}
